/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author Marcio
 */
public class ManangerEntity {
    
    private static EntityManagerFactory emF = null;
    private static EntityManager em = null;
    
    public static EntityManager getEntityManager() {
        if (emF == null) {
            emF = Persistence.createEntityManagerFactory("FrotasPU");
        }
        if (em == null) {
            em = emF.createEntityManager();
        }
        return em;
    }

    public static EntityManagerFactory getEntityManagerFactory() {
        if (emF == null) {
            emF = Persistence.createEntityManagerFactory("FrotasPU");
        }
        if (em == null) {
            em = emF.createEntityManager();
        }
        return emF;
    }
    
}
